CoolpexBody = Button.extend({
	duration: 0.6,
	orig_p:null,
	target_p:null,
	ctor: function (parent,zIndex,tag,normalImage, callback, back) {
		this._super(parent,zIndex,tag,normalImage, callback, back);
		this.init();
	},
	init: function () {
		var animFrames = [];
		for (var i = 0; i < 5; i++) {
			var str = "coolpex_body" + i + ".png";
			if(i == 0){
				str = "coolpex_body.png";
			}
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		var animation = new cc.Animation(animFrames, 0.2);
		this.openAction = cc.animate(animation);
		this.openAction.retain();
		
		animFrames = [];
		for (var i = 4; i >= 0; i--) {
			var str = "coolpex_body" + i + ".png";
			if(i == 0){
				str = "coolpex_body.png";
			}
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		animation = new cc.Animation(animFrames, 0.2);
		this.closeAction = cc.animate(animation);
		this.closeAction.retain();
		

		animFrames = [];
		var frame = cc.spriteFrameCache.getSpriteFrame("coolpex_body22.png");
		animFrames.push(frame);
		var frame = cc.spriteFrameCache.getSpriteFrame("coolpex_body2.png");
		animFrames.push(frame);
		var frame = cc.spriteFrameCache.getSpriteFrame("coolpex_body1.png");
		animFrames.push(frame);
		var frame = cc.spriteFrameCache.getSpriteFrame("coolpex_body.png");
		animFrames.push(frame);
		
		animation = new cc.Animation(animFrames, 0.2);
		this.closeAction2 = cc.animate(animation);
		this.closeAction2.retain();
		
		animFrames = [];
		for (var i = 11; i < 15; i++) {
			var str = "coolpex_body" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		animation = new cc.Animation(animFrames, 0.2);
		this.rollAction = cc.repeatForever(cc.animate(animation));
		this.rollAction.retain();
		
		animFrames = [];
		for (var i = 20; i < 22; i++) {
			var str = "coolpex_body" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		animation = new cc.Animation(animFrames, 0.2);
		this.rollAction2 = cc.repeatForever(cc.animate(animation));
		this.rollAction2.retain();
	},
	roll:function(){
		this.runAction(this.rollAction);
	},
	roll2:function(){
		this.runAction(this.rollAction2);
	},
	rollStop:function(){
		this.stopAllActions();
		this.setSpriteFrame("coolpex_body14.png");
	},
	rollStop2:function(){
		this.stopAllActions();
		this.setSpriteFrame("coolpex_body22.png");
	},
	openDoor:function(){
		var func = cc.callFunc(function(){
			this.setSpriteFrame("coolpex_body4.png");
		},this);
		var seq = cc.sequence(this.openAction,
				func);
		this.runAction(seq);
	},
	closeDoor:function(){
		var func = cc.callFunc(function(){
			this.setSpriteFrame("coolpex_body.png");
		},this);
		var seq = cc.sequence(this.closeAction,func);
		this.runAction(seq);
	},
	closeDoor2:function(){
		this.setVisible(true);
		var func = cc.callFunc(function(){
			this.setSpriteFrame("coolpex_body.png");
		},this);
		var seq = cc.sequence(this.closeAction2,func);
		this.runAction(seq);
	}
})